<template>
  <div>
    <el-row align='top' >
        <el-col :span="18" >
          <el-form label-width="80px">
            <el-form-item label="学科名称">
              <el-input @blur="onBlur" v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button size="small" @click="onClear">清除</el-button>
              <el-button type="primary" size="small" @click="$emit('subjectSearch',form.name)">搜索</el-button>
            </el-form-item>
          </el-form>
          </el-col>
        <el-col :span="6">
          <el-button type="success" icon="el-icon-edit" size="small" @click="$emit('addClick')">
            新增学科
          </el-button>
          </el-col>
      </el-row>
  </div>
</template>

<script>
export default {
  data () {
    return {
      form: {
        name: ''
      }
    }
  },

  created () {

  },

  methods: {
    // 清空
    onClear () {
      this.form.name = ''
      this.$emit('subjectSearch', this.form.name)
    },
    onBlur () {
      if (this.form.name === '') {
        this.$emit('subjectSearch', this.form.name)
      }
    }
  }
}
</script>

<style scoped lang='less'>
* {
  margin: 0;
}
.el-col:nth-child(2) {
    display: flex;
    justify-content: end;
  }
  .el-form-item{
    display: inline-block;
    height: 32px;
    margin-right: 10px;
    /deep/.el-form-item__content:nth-child(1) {
      margin-left: 0px !important;
    }
   /deep/.el-input__inner{
       height: 32px;
     }
  }
</style>
